package admin;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class GetResources {
	private List<Resources> list=new ArrayList<Resources>();
	public List<Resources> getData() {
		try {
			Class.forName("com.mysql.jdbc.Driver");
			Getconfig gc=new Getconfig();
			String url= gc.getParaValue("connectUrl");
			Connection conn=DriverManager.getConnection(url);
			String sql="select * from resources";
			PreparedStatement ps=conn.prepareStatement(sql);
			ResultSet rs=ps.executeQuery();
			while(rs.next()) {
				int id=rs.getInt("id");
				String title=rs.getString("title");	
				String urlr=rs.getString("url");
				String code=rs.getString("code");
				
				Resources src=new Resources();
				src.setId(id);
				src.setTitle(title);
				src.setUrl(urlr);
				src.setCode(code);
				list.add(src);
			}
			ps.close();
			conn.close();
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return list;
	}

//	public static void main(String[] args) {
//		// TODO Auto-generated method stub
//		getResources ggg=new getResources();
//		System.out.println(ggg.getData());
//	}

}
